package com.ruoyi.web.controller.kaoyan.vo;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.kaoyan.domain.EducationPartner;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * 搭档vo类
 * @author admin
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PartnerVo {

    private Long id;

    private Long userId;
    /**
     * 用户id
     */
    private String userName;

    private Long applyUserId;
    /**
     * 申请成为搭档的用户姓名
     */
    private String applyUserName;
    /**
     * 匹配通过标记（null：待审核 1：已匹配 0：已拒绝）
     */
    private String matchFlag;

    /**
     * 邀请反馈消息
     */
    private String message;

    public PartnerVo(EducationPartner partner, Map<Long, String> userMap, Map<Long, String> user2Map){
        this.id = partner.getId();
        this.userId = partner.getUserId();
        this.userName = userMap.get(partner.getUserId());
        this.applyUserId = partner.getApplyUserId();
        this.applyUserName = user2Map.get(partner.getApplyUserId());
        this.matchFlag = StringUtils.isNull(partner.getMatchFlag()) ? "null" : partner.getMatchFlag().toString();
        this.message = "";
    }

    public PartnerVo(EducationPartner partner, Map<Long, String> user2Map){
        this.id = partner.getId();
        this.applyUserId = partner.getApplyUserId();
        this.applyUserName = user2Map.get(partner.getApplyUserId());
        this.matchFlag = StringUtils.isNull(partner.getMatchFlag()) ? "null" : partner.getMatchFlag().toString();
        String agree = applyUserName + "同意了你的邀请";
        String reject = applyUserName + "拒绝了你的邀请";
        this.message = "1".equals(matchFlag) ? agree : reject;
    }
}
